﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ProtoBuf;

namespace ZyGames.DZPocker.Model
{
	public enum GotyeChatTargetType
	{  /// <summary>
		/// 单聊
		/// </summary>
		GotyeChatTargetTypeUser,
		/// <summary>
		/// 群聊
		/// </summary>
		GotyeChatTargetTypeRoom,
	};

	public class TalkRoomManager
	{
		public static TalkRoomManager Instance = new TalkRoomManager();
		private int _index;
		private List<TalkRoom> _roomList;

		public int Index
		{
			get { return _index; }
			set { _index = value; }
		}

		public TalkRoomManager()
		{
			Index = ConfigEnvSet.GetInt("GameSetting.TalkingRoomID", 1);
			_roomList = new List<TalkRoom>();
		}

		public int GetRoomID()
		{
			return this.Index++;
		}

		public bool InsertRoom(TalkRoom room)
		{
			if (this._roomList.Contains(room))
				return false;
			this._roomList.Add(room);
			return true;
		}
	}

	/// <summary>
	/// 聊天室
	/// </summary>
	[Serializable, ProtoContract]
	public class TalkRoom
	{
		public TalkRoom(long id, int roomMasterUserId, string name = null, GotyeChatTargetType type = GotyeChatTargetType.GotyeChatTargetTypeRoom, string icon = null, string info = null)
		{
			this.ID = id;
			this.RoomMasterUserID = roomMasterUserId;
			this.Name = name;
			this.Type = type;
			this.Icon = icon;
			this.Info = info;
		}
		[ProtoMember(1)]
		public long ID { get; set; }

		[ProtoMember(2)]
		public string Name { get; set; }

		[ProtoMember(3)]
		public GotyeChatTargetType Type { get; set; }

		[ProtoMember(4)]
		public string Icon { get; set; }

		[ProtoMember(5)]
		public string Info { get; set; }

		[ProtoMember(6)]
		public int RoomMasterUserID { get; set; }
	}
}
